package com;

import com.cms.filter.PermissionFilter;
import com.jfinal.core.JFinalFilter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
/**
 * 启动程序
 * 
 * @author ruoyi
 */
@SpringBootApplication
public class MainApplication
{
    public static void main(String[] args)
    {
        // System.setProperty("spring.devtools.restart.enabled", "false");
        SpringApplication.run(MainApplication.class, args);
        System.out.println("(♥◠‿◠)ﾉﾞ  若依启动成功   ლ(´ڡ`ლ)ﾞ  \n" +
                " .-------.       ____     __        \n" +
                " |  _ _   \\      \\   \\   /  /    \n" +
                " | ( ' )  |       \\  _. /  '       \n" +
                " |(_ o _) /        _( )_ .'         \n" +
                " | (_,_).' __  ___(_ o _)'          \n" +
                " |  |\\ \\  |  ||   |(_,_)'         \n" +
                " |  | \\ `'   /|   `-'  /           \n" +
                " |  |  \\    /  \\      /           \n" +
                " ''-'   `'-'    `-..-'              ");
    }

    @Bean
    public FilterRegistrationBean securityFilter() {
        //配置无需过滤的路径或者静态资源，如：css，imgage等
        StringBuffer excludedUriStr = new StringBuffer();
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new PermissionFilter());
        registration.addUrlPatterns("/*");
        registration.setName("permissionFilter");
        registration.setOrder(1);
        return registration;
    }
    @Bean
    public FilterRegistrationBean JFinalFilter() {
        //配置无需过滤的路径或者静态资源，如：css，imgage等
        StringBuffer excludedUriStr = new StringBuffer();
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new JFinalFilter());
        registration.addUrlPatterns("/*");
        registration.setName("jfinal");
        registration.addInitParameter("configClass","com.cms.config.CmsConfig");
        registration.setOrder(2);
        return registration;
    }
}